package com.naiterui.ehp.bs.wechat.protocol.msg.template;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * 跳小程序的模板消息
 * @author zhoupeipei
 * @date 2019-06-18 19:55
 * @since 1.0.0
 */
public class TemplateMp extends TemplateMsg{
    private static final long serialVersionUID = 7426769955526346022L;
    @JsonProperty("miniprogram")
    private MiniProgram miniProgram;

    /**
     * 跳转小程序指定页面的模板消息
     * @param openId
     * @param templateId
     * @param appId
     * @param page
     */
    public TemplateMp(String openId, String templateId, String appId, String page){
        super(openId, templateId);
        miniProgram = new MiniProgram(appId, page);
    }


    public MiniProgram getMiniProgram() {
        return miniProgram;
    }

    public void setMiniProgram(MiniProgram miniProgram) {
        this.miniProgram = miniProgram;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

    private class MiniProgram {
        @JsonProperty("appid")
        private String appId;
        @JsonProperty("pagepath")
        private String pagePath;

        public MiniProgram(String appId, String pagePath) {
            this.appId = appId;
            this.pagePath = pagePath;
        }

        public String getAppId() {
            return appId;
        }

        public void setAppId(String appId) {
            this.appId = appId;
        }

        public String getPagePath() {
            return pagePath;
        }

        public void setPagePath(String pagePath) {
            this.pagePath = pagePath;
        }

        @Override
        public String toString() {
            return ToStringBuilder.reflectionToString(this);
        }
    }
}
